﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Chapter09
{
    using Chapter09.View;

    /// <summary>
    /// 第9章 命令
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            #region 01 理解命令
            #endregion

            #region 02 命令模型
            /*
             * 01 ICommand 接口
             * 02 RouteCommand 类
             * 03 RouteUICommand 类
             * 04 命令库
             * */
            #endregion

            #region 03 执行命令
            /*
             * 01 命令源
             * 02 命令绑定
             * 03 使用多命令源
             * 04 微调命令
             * 05 直接调用命令
             * 06 禁用命令
             * 07 具有内置命令的控件
             * */
            #endregion

            #region 04 高级命令
            /*
             * 01 自定义命令
             * 02 在不同位置使用相同的命令
             * 03 使用命令参数
             * 04 跟踪和翻转命令
             * */
            #endregion

            #region 05 小结
            #endregion
        }

        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Command == ApplicationCommands.Open)
            {
                var button = e.Source as Button;
                if (button != null)
                {
                    if (button == button1)
                    {
                        Demo(new TestNewCommandWindow());
                    }
                    if (button == button2)
                    {
                        Demo(new SimpleDocumentWindow());
                    }
                    if (button == button3)
                    {
                        Demo(new TwoDocumentWindow());
                    }
                    if (button == button4)
                    {
                        Demo(new MonitorWindow());
                    }
                }
            }
        }

        private void Demo(Window window)
        {
            window.Owner = this;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.ShowDialog();
        }
    }
}
